package com.vishop.daos;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.vishop.models.Bestelling;

@Repository
@Transactional
public class BestellingDaoImpl
{
	@Autowired
	private SessionFactory sessionFactory;

	public Bestelling getById(int id){
		return (Bestelling) sessionFactory.getCurrentSession().get(Bestelling.class, id);
	}
	
	@SuppressWarnings("unchecked")
	public Collection<Bestelling> getAllBestelling(){
		return sessionFactory.getCurrentSession().createQuery("from Merk").list();
	}
	
	@SuppressWarnings("unchecked")
	public Collection<Bestelling> getAllBestellingByPersoon(){
		return sessionFactory.getCurrentSession().createQuery("from Merk").list();
	}

	public int save(Bestelling bestelling){
		return (Integer) sessionFactory.getCurrentSession().save(bestelling);
	}
}
